package com.zjb.openfirecli.config;

import com.zjb.openfirecli.services.OpenfireCliServices;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@RequiredArgsConstructor
@EnableConfigurationProperties(OpenfireCliProperties.class)
public class OpenfireCliConfiguration {

    private final OpenfireCliProperties openfireCliProperties;

    @Bean
    @ConditionalOnMissingBean(OpenfireCliServices.class)
    public OpenfireCliServices openfireCliServices() {
        return new OpenfireCliServices(openfireCliProperties.getHostName(), openfireCliProperties.getHostAddress(), openfireCliProperties.getHostPort());
    }

}
